package com.springboot.springbootweb.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.springbootweb.service.JcDemoService;
import com.springboot.springbootweb.model.JcDemo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 基础_demo表 前端控制器
 * </p>
 *
 * @author gwj
 * @since 2021-09-10
 */
@RestController
@RequestMapping("/jc-demo")
public class JcDemoController {

    @Autowired
    private JcDemoService jcDemoService;

    @GetMapping("/getUser")
    public JcDemo getUser(@RequestParam(value = "id") String id) {

        return jcDemoService.getById(id);
    }

    @GetMapping("/getUserByPage")
    public Page getProjectList(HttpServletRequest request) {
        int offset = Integer.parseInt(request.getParameter("offset"));
        int limit = Integer.parseInt(request.getParameter("limit"));
        Integer T_RADIO = Integer.parseInt(request.getParameter("T_RADIO"));
        Page page = new Page<>(offset / limit + 1, limit);
        Page projectWinInfoList = (Page) jcDemoService.getAll(page, T_RADIO);
        return projectWinInfoList;
    }
}
